package main.java.state.before;

public class Lift implements ILift {
    //声明一个记录当前状态的变量
    private int state;

    @Override
    public void setState(int state) {
        this.state = state;
    }

    @Override
    public void opne() {
        switch (state) {
            case OPENING_STATE:
                break;
            case CLOSING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case RUNNING_STATE:
                System.out.println("电梯打开了...");
                setState(OPENING_STATE);
                break;
            case STOPPING_STATE:

                break;

        }
    }

    @Override
    public void close() {
        switch (state) {
            case OPENING_STATE:
                System.out.println("电梯关闭了...");
                setState(CLOSING_STATE);
                break;
            case CLOSING_STATE:

                break;
            case RUNNING_STATE:

                break;
            case STOPPING_STATE:

                break;

        }
    }

    @Override
    public void run() {
        switch (state) {
            case OPENING_STATE:

                break;
            case CLOSING_STATE:
                System.out.println("电梯开始运行了...");
                setState(CLOSING_STATE);
                break;
            case RUNNING_STATE:

                break;
            case STOPPING_STATE:
                System.out.println("电梯开始运行了...");
                setState(CLOSING_STATE);
                break;

        }
    }

    @Override
    public void stop() {
        switch (state) {
            case OPENING_STATE:

                break;
            case CLOSING_STATE:
                System.out.println("电梯停止了...");
                setState(CLOSING_STATE);
                break;
            case RUNNING_STATE:
                System.out.println("电梯停止了...");
                setState(CLOSING_STATE);
                break;
            case STOPPING_STATE:

                break;

        }
    }
}
